local Lua__shuangpai = fk.CreateSkill {
    name = "Lua__shuangpai",
}

Fk:loadTranslationTable{
  ["Lua__shuangpai"] = "双排",
  ["$Lua__shuangpai1"] = "传说中的海军卡普中将。",
  [":Lua__shuangpai"] = "游戏开始时或有角色死亡后，若你的友方角色只有一位，你与其依次各执行一个额外出牌阶段。你与其技能使用时，可对一名其他角色造成一点伤害。你使用牌无次数限制",
  ["@@Lua__shuangpai"] = "双排",
  ["#Lua__shuangpai-choose"] = "双排：选择一名角色造成1点伤害。",
}

-- 其他角色出牌阶段可触发猫猫
Lua__shuangpai:addEffect(fk.GameStart, {
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(Lua__shuangpai.name) then
        local num = 0
        for _, p in ipairs(player.room:getOtherPlayers(player)) do
            if p:isFriend(player) then
                num = num + 1
            end
        end
        return num == 1
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "@@Maomao", 0)
    for _, p in ipairs(player.room:getOtherPlayers(player)) do
        if p:isFriend(player) then
            room:setPlayerMark(player, "@@Lua__shuangpai", 1)
            room:setPlayerMark(p, "@@Lua__shuangpai", 1)
            player:gainAnExtraPhase(Player.Play,Lua__shuangpai.name)
            p:gainAnExtraPhase(Player.Play,Lua__shuangpai.name)
        end
    end
  end
})


Lua__shuangpai:addEffect(fk.Death, {
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
      if player:hasSkill(Lua__shuangpai.name) then
          local num = 0
          for _, p in ipairs(player.room:getOtherPlayers(player)) do
              if p:isFriend(player) then
                  num = num + 1
              end
          end
          return num == 1
      end
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      room:setPlayerMark(player, "@@Maomao", 0)
      for _, p in ipairs(player.room:getOtherPlayers(player)) do
          if p:isFriend(player) then
              room:setPlayerMark(player, "@@Lua__shuangpai", 1)
              room:setPlayerMark(p, "@@Lua__shuangpai", 1)
              player:gainAnExtraPhase(Player.Play,Lua__shuangpai.name)
              p:gainAnExtraPhase(Player.Play,Lua__shuangpai.name)
          end
      end
    end,
})

Lua__shuangpai:addEffect(fk.SkillEffect, {
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(Lua__shuangpai.name) and data.skill.name ~= Lua__shuangpai.name and data ~= self and target and target:getMark("@@Lua__shuangpai") == 1 and
        table.contains(target:getSkillNameList(), data.skill:getSkeleton().name) and not data.skill.is_delay_effect 
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local targets = room:askToChoosePlayers(target, {
            targets = room:getOtherPlayers(target),
            min_num = 1,
            max_num = 1,
            prompt = "#Lua__shuangpai-choose",
            skill_name = Lua__shuangpai.name,
            cancelable = true,
         })
        if #targets > 0 then
            event:setCostData(self, {target = targets[1]})
            return true
        end
      end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local targetAAA = event:getCostData(self).target
      room:damage {
        from = target,
        to = targetAAA,
        damage = 1,
      }
    end
  })

  Lua__shuangpai:addEffect("targetmod", {
    bypass_times = function(self, player, skill, scope, card, to)
      return player:hasSkill(Lua__shuangpai.name) and card 
    end,
})


return Lua__shuangpai 